/// <reference path="F:\Html5 Game\Game project\js\libs\kangax-fabric-48.306.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\DBAbstractionLayer.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\GameCanvas.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Node.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\NodeType.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Planet.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Region.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Scale.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\System.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Universe.js"/>
/// <reference path="F:\Html5 Game\Game project\js\classes\Utilities.js"/>
var Utilities = function () {
    
    //Takes radius of circle and number of points as arguments, returns array of coordinates
    this.CirclePointGenerator = function (radius, nrpts) {
        var edgeoffset = 10;
        var fillradius = radius - edgeoffset;
        var offset = radius * Math.PI / nrpts;
        var arrx = new Array();
        var arry = new Array();
        var coordarray = new Array();
        var q = Math.random() * (Math.PI * 2);
        var r = Math.sqrt(Math.random());
        var x = (fillradius * r) * Math.cos(q);
        var y = (fillradius * r) * Math.sin(q);

        arrx[0] = x;
        arry[0] = y;
        coordarray[0] = new Coordinate(x, y);

        //Start Generating Points
        for (var j = 1; j < nrpts; j++) {
            var test = 1;
            while (test > 0) {
                var q = Math.random() * (Math.PI * 2);
                var r = Math.sqrt(Math.random());
                var x = (fillradius * r) * Math.cos(q);
                var y = (fillradius * r) * Math.sin(q);
                test = 0;
                //Check if point lies within radius of other points
                for (k = 0; k < j; k++) {
                    if (Math.sqrt(Math.pow(x - arrx[k], 2) + Math.pow(y - arry[k], 2)) < offset) {
                        test = 1;
                    }
                }
            }
            arrx[j] = x;
            arry[j] = y;
            coordarray[j] = new Coordinate(x, y);
        }
        return coordarray;
    }
}